<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .container{
            display: flex;
            justify-content: center;
        }
        .left{
            width: 200px;
            height: 200px;
            background: url(../img/1.jpg);
            position: relative;
        }
        .shadow{
            height: 100px;
            width: 100px;
            display: none;
            background: rgba(0, 0, 0, .4);
            position: absolute;
        }
        .left:hover .shadow{
            display: block;
        }
        .right{
            width: 300px;
            height: 300px;
            border:1px solid red;
            position:relative;
            overflow: hidden;
            display: none;
        }
      
        .right img{
            width: 400px;
            height: 400px;
            position: absolute;
        }
    </style>
</head>
<body>
        <div class="container">
                <div class="left">
                    <div class="shadow"></div>
                </div>
                <div class="right">
                    <img src="../img/1.jpg" alt="">
                </div>
        </div>
    <script>
        function $(e){
            return document.querySelector(e);
        }
        $('.left').onmousemove=function(e){
            $('.right').style.display='block';
            var x=e.clientX-this.offsetLeft;
            var y=e.clientY-this.offsetTop;
           x=x-50;
           y=y-50;
           x=x<0?0:x;
           y=y<0?0:y;
           x=x>100?100:x;
           y=y>100?100:y;
           $('.shadow').style.left=x+'px';
           $('.shadow').style.top=y+'px';
           var x2=x*2;
           var y2=y*2;
           $('img').style.left=-x2+'px';
           $('img').style.top=-y2+'px';

        }
        $('.left').onmouseleave=function(e){
            $('.right').style.display='none';
        }
    </script>
</body>
</html>